
#ifndef  BINARYTREE_H
#define  BINARYTREE_H

#include "Util.h"

class BinaryTree : public util::Task {
public:
    BinaryTree();
    ~BinaryTree() override;
    void run() override;

    struct Node{
        int value;
        Node * left;
        Node * right;
        Node(int value)
        :Node(value, nullptr, nullptr)
        {
        }
        Node(int value, Node * left, Node * right)
        : value(value)
        , left(left)
        , right(right)
        {
        }
    };

private:
    Node * construct(int * preStart, int preLength, int * inStart, int inLength);
private:
    void levelTraversal();
    void preorderTraversal(); 
    void inorderTraversal();
    void postorderTraversal();

private:
    void init();
    void deinit();
private:
    Node * root;    
};

#endif   /* BINARYTREE_H */
